<template>
  <div class="base-progress">
    <div class="inner" :style="{ width: w + '%' }"></div>
    <span :class="{ white: w > 60 }">{{ w }}%</span>
  </div>
</template>

<script>
export default {
  // props: ['w']
  // props:{w:Number}
  props: {
    w: {
      type: Number,
      // required: true,
      default: 0,
      validator(value) {
        if (value >= 0 && value <= 100) {
          return true;
        } else {
          console.error("必须介于0-100的数字");
          return false;
        }
      },
    },
  },
};
</script>

<style scoped>
.white {
  color: white !important;
}
.base-progress {
  height: 26px;
  width: 400px;
  border-radius: 5px;
  background-color: rgba(255, 255, 255);
  border: 1px solid black;
  margin-bottom: 20px;
  box-sizing: border-box;
  line-height: 26px;
  position: relative;
}
.base-progress span {
  position: absolute;
  top: 0;
}
.inner {
  background-color: rgba(0, 0, 255, 0.364);
  border-radius: 5px;
  height: 26px;
  line-height: 26px;
}
</style>